var __extends =
    (this && this.__extends) ||
    (function () {
      var t = function (e, n) {
        return (t =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (t, e) {
              t.__proto__ = e;
            }) ||
          function (t, e) {
            for (var n in e)
              Object.prototype.hasOwnProperty.call(e, n) && (t[n] = e[n]);
          })(e, n);
      };
      return function (e, n) {
        function i() {
          this.constructor = e;
        }
        if ("function" != typeof n && null !== n)
          throw new TypeError(
            "Class extends value " + String(n) + " is not a constructor or null"
          );
        t(e, n),
          (e.prototype =
            null === n
              ? Object.create(n)
              : ((i.prototype = n.prototype), new i()));
      };
    })(),
  LibraryRoomDialog = (function (t) {
    function e() {
      var e = t.call(this) || this;
      return (
        (e.roomStep = "0"),
        (e.max = 100),
        (e.min = 0),
        (e.step = 1),
        (e.num = 0),
        e.btn_library_back.on(Laya.Event.CLICK, e, e.onLibraryBackPre),
        e.radiogroup_shufang.on(Laya.Event.CLICK, e, e.onLibraryselect),
        WebSocketService.addListener({
          caller: e,
          code: 1451,
          method: e.onLoadMySelfMoneyOnLibraryData,
        }),
        WebSocketService.addListener({
          caller: e,
          code: 1515,
          method: e.onLoadShuFangYanXiData,
        }),
        e.btn_shufang_yanxi.on(Laya.Event.CLICK, e, e.onShuFangYanXiDidClick),
        e.btn_shufang_dele.on(Laya.Event.CLICK, e, e.onDidClickShuFangItemFn),
        e.btn_shufang_add.on(Laya.Event.CLICK, e, e.onDidClickShuFangItemFn),
        e.slider_shufang.on(Laya.Event.CHANGE, e, e.onSliderShuFangChange),
        (e.slider_shufang.min = 0),
        (e.slider_shufang.max = e.max),
        e
      );
    }
    return (
      __extends(e, t),
      (e.openLibraryDialog = function (t) {
        return (
          null == this.libRoomV && (this.libRoomV = new e()),
          this.libRoomV.popup(!0),
          WebSocketService.send({ c: 1451 }),
          (this.libRoomV.fangwu_lvl = t),
          (this.libRoomV.label_yanxi_content.text = "0金0分钟/0本"),
          (this.libRoomV.slider_shufang.value = 0),
          (this.libRoomV.radiogroup_shufang.selectedIndex = -1),
          this.libRoomV
        );
      }),
      (e.prototype.onDidClickShuFangItemFn = function (t) {
        "item0" == t.target.name
          ? ((this.num = this.num - this.step),
            this.num < this.min && (this.num = this.min),
            (this.slider_shufang.value = this.num))
          : "item1" == t.target.name &&
            ((this.num = this.num + this.step),
            this.num > this.max && (this.num = this.max),
            (this.slider_shufang.value = this.num)),
          this.dealYanXiFeeWithMoney(),
          (this.label_yanxi_content.text = this.dealYanXiFeeWithMoney());
      }),
      (e.prototype.onSliderShuFangChange = function () {
        (this.num = this.slider_shufang.value),
          (this.label_yanxi_content.text = this.dealYanXiFeeWithMoney());
      }),
      (e.prototype.dealYanXiFeeWithMoney = function () {
        this.fangwu_lvl;
        var t = "";
        return (
          (t = this.preFeeMoneyNumber(5 - this.radio_inde) * this.num + "金"),
          this.preFeeTimerNumber() * this.num + "分钟",
          t +
            this.ChangeHourMinutestr(this.preFeeTimerNumber() * this.num) +
            "/" +
            this.num +
            "本"
        );
      }),
      (e.prototype.ChangeHourMinutestr = function (t) {
        var e = Math.floor(t / 60),
          n = Math.floor(t % 60);
        return e < 1 ? n + "分钟" : e + "小时" + n + "分钟";
      }),
      (e.prototype.onShuFangYanXiDidClick = function () {
        var t = this.num,
          e = 5 - this.radio_inde;
        WebSocketService.send({ c: 1515, d: { l: e, c: t } });
      }),
      (e.prototype.onLoadShuFangYanXiData = function (t) {
        0 == t.code
          ? (ToastView.toastView(t.data), this.close())
          : (this.close(), ToastView.toastView(t.msg));
      }),
      (e.prototype.preFeeMoneyNumber = function (t) {
        var e = 0;
        return (
          1 == t
            ? (e = 10)
            : 2 == t
            ? (e = 20)
            : 3 == t
            ? (e = 30)
            : 4 == t
            ? (e = 40)
            : 5 == t && (e = 50),
          e
        );
      }),
      (e.prototype.preFeeTimerNumber = function () {
        var t = 0;
        return (
          1 == this.fangwu_lvl
            ? (t = 150)
            : 2 == this.fangwu_lvl
            ? (t = 120)
            : 3 == this.fangwu_lvl
            ? (t = 90)
            : 4 == this.fangwu_lvl
            ? (t = 60)
            : 5 == this.fangwu_lvl && (t = 30),
          t
        );
      }),
      (e.prototype.onLoadMySelfMoneyOnLibraryData = function (t) {}),
      (e.prototype.onLibraryselect = function (t) {
        if ("" != t.target.name) {
          "item0" == t.target.name
            ? ((this.label_shufang_select_msg.text = "五级经验书"),
              (this.radio_inde = 0))
            : "item1" == t.target.name
            ? ((this.label_shufang_select_msg.text = "四级经验书"),
              (this.radio_inde = 1))
            : "item2" == t.target.name
            ? ((this.label_shufang_select_msg.text = "三级经验书"),
              (this.radio_inde = 2))
            : "item3" == t.target.name
            ? ((this.label_shufang_select_msg.text = "二级经验书"),
              (this.radio_inde = 3))
            : "item4" == t.target.name &&
              ((this.label_shufang_select_msg.text = "一级经验书"),
              (this.radio_inde = 4)),
            (this.slider_shufang.value = 0),
            (this.label_yanxi_content.text = "0金0分钟/0本");
        }
      }),
      (e.prototype.onLibraryBackPre = function () {
        this.close();
      }),
      (e.close = function () {
        this.libRoomV && (this.libRoomV = null);
      }),
      e
    );
  })(ui.Estatemarket.LibraryRoomDialogUI);
